<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>batch_update (SpreadsheetExamples)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File SpreadsheetExamples.rb, line 163</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">batch_update</span>(<span class="ruby-identifier">batch_data</span>, <span class="ruby-identifier">cellfeed_uri</span>)
    <span class="ruby-identifier">batch_uri</span> = <span class="ruby-identifier">cellfeed_uri</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/batch'</span>

    <span class="ruby-identifier">batch_request</span> = <span class="ruby-value str">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt; \\\n  &lt;feed xmlns=\&quot;http://www.w3.org/2005/Atom\&quot; \\\n  xmlns:batch=\&quot;http://schemas.google.com/gdata/batch\&quot; \\\n  xmlns:gs=\&quot;http://schemas.google.com/spreadsheets/2006\&quot; \\\n  xmlns:gd=\&quot;http://schemas.google.com/g/2005\&quot;&gt;\n  &lt;id&gt;\#{cellfeed_uri}&lt;/id&gt;\n&quot;</span>

    <span class="ruby-identifier">batch_data</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">batch_request_data</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">version_string</span> = <span class="ruby-identifier">get_version_string</span>(<span class="ruby-identifier">cellfeed_uri</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span>
          <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:cell_id</span>])
      <span class="ruby-identifier">data</span> = <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:data</span>]
      <span class="ruby-identifier">batch_id</span> = <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:batch_id</span>]
      <span class="ruby-identifier">cell_id</span> = <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:cell_id</span>]
      <span class="ruby-identifier">row</span> = <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:cell_id</span>][<span class="ruby-value">1</span>,<span class="ruby-value">1</span>]
      <span class="ruby-identifier">column</span> = <span class="ruby-identifier">batch_request_data</span>[<span class="ruby-identifier">:cell_id</span>][<span class="ruby-value">3</span>,<span class="ruby-value">1</span>]
      <span class="ruby-identifier">edit_link</span> = <span class="ruby-identifier">cellfeed_uri</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">cell_id</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">version_string</span>
   
      <span class="ruby-identifier">batch_request</span><span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;          &lt;entry&gt;\n            &lt;gs:cell col=\&quot;\#{column}\&quot; inputValue=\&quot;\#{data}\&quot; row=\&quot;\#{row}\&quot;/&gt;\n            &lt;batch:id&gt;\#{batch_id}&lt;/batch:id&gt;\n            &lt;batch:operation type=\&quot;update\&quot; /&gt;\n            &lt;id&gt;\#{cellfeed_uri}/\#{cell_id}&lt;/id&gt;\n            &lt;link href=\&quot;\#{edit_link}\&quot; rel=\&quot;edit\&quot; type=\&quot;application/atom+xml\&quot; /&gt;\n          &lt;/entry&gt;\n&quot;</span>
  <span class="ruby-keyword kw">end</span>
    
    <span class="ruby-identifier">batch_request</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">'&lt;/feed&gt;'</span>
    <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">batch_uri</span>, <span class="ruby-identifier">batch_request</span>)
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>